package com.wavehi.login.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.test.web.servlet.setup.MockMvcConfigurer;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * @Description
 * @Author WaveHi
 * @Date 30/11/2021 下午 12:43
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 */
@Configuration
public class MyWebMvcConfiguration implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        File file = null;
        try {
            file = ResourceUtils.getFile("module_resource");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        registry.addResourceHandler("/")
                .addResourceLocations(file.getAbsolutePath() + "/");
    }
}
